﻿using Microsoft.AspNetCore.Mvc;
using TestLargeModel.Services;

namespace TestLargeModel.Controllers
{
    public class AIController : Controller
    {
        private readonly AIService _aiService;

        public AIController(AIService aiService)
        {
            _aiService = aiService;
        }

        [HttpPost]
        public async Task<IActionResult> GetAIResponse(string inputText)
        {
            // 确保 inputText 参数不为空
            if (!string.IsNullOrEmpty(inputText))
            {
                var response = await _aiService.CallDoubaiAIAsync(new { Input = inputText }); // 将输入文本传递给AI服务
                ViewBag.Response = response;
            }
            return View("Index"); // 返回到 Index 视图
        }
    }
}
